import File from './File';
import { joinPath } from '../Utils';
import Context from '../Context';
import VFile = require('vinyl');

export default class BootFile extends File {
    public readonly type: FileType = FileType.boot;
    public readonly _contents = '// boot';

    constructor(cx: Context) {
        super(cx, { src: 'BOOT.js', id: 'BOOT.js', updateTime: Date.now() });
    }

    public async doLoad() {
        this.cx.bootDependencies.forEach((e, i) => {
            this.dependencies[i] = e;
        });
        await this.cx.defaultLoader.load(this);
    }

    public toVinylFile(): VFile | undefined {
        if (this.cx.bootDependencies.length) {
            return super.toVinylFile();
        } else {
            return undefined;
        }
    }

}
